<?php
/**
 * Created by PhpStorm.
 * User: shuai
 * Date: 2016/7/27
 * Time: 20:59
 * 精确查找
 */
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_app_class('admin', 'admin', 0);
pc_base::load_app_class('foreground');
pc_base::load_sys_class('format', '', 0);
pc_base::load_sys_class('form', '', 0);
class exact_find extends admin {

    public function __construct() {
        $this->shuafen_download_times = pc_base::load_model('shuafen_download_times_model');
        $this->member = pc_base::load_model('member_model');
        parent::__construct();
    }

    public function vip_member(){
        $page = max(intval($_GET['page']), 1);
        $where = "trash = 0 and vip = 'Y'";
//        var_dump(trim($_GET['username']));die;
        if(isset($_GET['username']) && trim($_GET['username'])){
            $tel=$_GET['username'];
            $where .= " AND username = ".trim($_GET['username']);
        }
        $infos = $this->member->listinfo($where,'vip_top desc , vip_top_time desc , vip_time desc', $page);
        $pages = $this->member->pages;
        $top = array('0'=>'否','1'=>'是');
        $sex = array('0'=>'男','1'=>'女');
        include $this->admin_tpl('member/vip_member');
    }

    public function top_vip_member(){
        $userid = $_GET['userid'];
        if($userid){
            $action = $_GET['action'];
            if($action){
                $data['vip_top'] = 0;
                $data['vip_top_time'] = 0;
            }else{
                $data['vip_top'] = 1;
                $data['vip_top_time'] = SYS_TIME;
            }
            $this->member->update($data,array('userid'=>$userid));
            showmessage(L('操作成功'), 'index.php?m=shuafen&c=exact_find&a=vip_member');
        }
    }

    public function svip_member(){
        $page = max(intval($_GET['page']), 1);
        $where = "trash = 0";
        if(isset($_GET['username']) && trim($_GET['username'])){
            $tel=$_GET['username'];
            $where .= " AND username = ".trim($_GET['username']);
        }
        $infos = $this->member->listinfo($where,'svip_top desc , svip_top_time desc , register_time desc', $page);
        $pages = $this->member->pages;
        $top = array('0'=>'否','1'=>'是');
        $sex = array('0'=>'男','1'=>'女');
        include $this->admin_tpl('member/svip_member');
    }

    public function top_svip_member(){
        $userid = $_GET['userid'];
        if($userid){
            $action = $_GET['action'];
            if($action){
                $data['svip_top'] = 0;
                $data['svip_top_time'] = 0;
            }else{
                $data['svip_top'] = 1;
                $data['svip_top_time'] = SYS_TIME;
            }
            $this->member->update($data,array('userid'=>$userid));
            showmessage(L('操作成功'), 'index.php?m=shuafen&c=exact_find&a=svip_member');
        }
    }

    public function vip_down_num(){
        if (isset($_POST['dosubmit'])) {
            $data['vip_down_times'] = $_POST['vip_down_times'];
            $this->shuafen_download_times->update($data, array('id'=>$_POST['id']));
            showmessage(L('修改成功'), 'index.php?m=shuafen&c=exact_find&a=vip_down_num');
        }else{
            $num = $this->shuafen_download_times->get_one();
        }
        include $this->admin_tpl('download/vip_down_num');
    }

    public function svip_down_num(){
        if (isset($_POST['dosubmit'])) {
            $data['svip_down_times'] = $_POST['svip_down_times'];
            $this->shuafen_download_times->update($data, array('id'=>$_POST['id']));
            showmessage(L('修改成功'), 'index.php?m=shuafen&c=exact_find&a=svip_down_num');
        }else{
            $num = $this->shuafen_download_times->get_one();
        }
        include $this->admin_tpl('download/svip_down_num');
    }


}
